/*
Copyright (C) Ariff Ehsan, Abdul Hadi Fikri

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*  Author : Ariff Ehsan,Abdul Hadi Fikri
 *  Date   : June 24, 2009
 */


#include <system.h>
#include <leds/leds.h>
/**
*CODE FUNCTIONALITY
*
*--Function name called by user of this module is in section "Provides", "Uses" is for any function 
*--name this module need to call in turn to signaled an event for the user.
*
*Interface module_name{
*	Provides{
*		command LEDS_init();
*		command LEDS_on(PINxn);
*		command LEDS_off(PINxn);
*		command LEDS_toggle(PINxn);
*		command LEDS_set(value);
*	}
*}
*
*--Component in call section are function name which this module use from other module in order to complete its
*--tasks, event in turn is any event siganalled by the other module(s).  
*
*Component{
*	call{
*		SYSTEM HARDWARE-> SET_BIT(REG NAME,REG BIT NAME);
*		SYSTEM HARDWARE-> CLR_BIT(REG NAME,REG BIT NAME);
*		SYSTEM HARDWARE-> FLIP_BIT(REG NAME,REG BIT NAME);
*	}
*}
*
**/
/********************************************************************************************/
/*                                  Clients/Command Call                                    */
/********************************************************************************************/
void LEDS_init(void) {
	/* initialize port as output */
	LEDS_DDR |= (1<<LEDS_LED0)|(1<<LEDS_LED1)|(1<<LEDS_LED2)|(1<<LEDS_LED3)|(1<<LEDS_LED4)|(1<<LEDS_LED5)|(1<<LEDS_LED6)|(1<<LEDS_LED7);	
}

void LEDS_on(uint8_t pin) {
	SET_BIT(LEDS_PORT, pin);
}


void LEDS_off(uint8_t pin) {
	CLR_BIT(LEDS_PORT, pin);
}


void LEDS_set(uint8_t value) {	
	LEDS_PORT = value;
}


void LEDS_toggle(uint8_t pin) {
	FLIP_BIT(LEDS_PORT, pin);
}

